﻿CREATE TABLE [Reporting].[ErrorLog]
(
	[ErrorLogID] BIGINT IDENTITY(1,1) NOT NULL CONSTRAINT [REPORTING_ErrorLog_ErrorLogID] PRIMARY KEY,
	[ErrorType] NVARCHAR(250) NOT NULL CONSTRAINT [FK_ErrorLog_TO_ErrorType_ON_Enum] FOREIGN KEY ([ErrorType]) REFERENCES [Reporting].[ErrorType]([Enum]),
	[ErrorAction] NVARCHAR(25) NOT NULL CONSTRAINT [REPORTING_ErrorLog_ErrorAction] DEFAULT ('UNKNOWN'),
	[TableName] NVARCHAR(50) NOT NULL CONSTRAINT [REPORTING_ErrorLog_TableName] DEFAULT ('UNKNOWN'),
	[Metadata] XML NOT NULL CONSTRAINT [REPORTING_ErrorLog_Metadata] DEFAULT ('NONE'),
	[CreatedBy] NVARCHAR(250) NOT NULL CONSTRAINT [REPORTING_ErrorLog_CreatedBy] DEFAULT SYSTEM_USER,	
	[DateCreated] DATETIME NOT NULL CONSTRAINT [REPORTING_ErrorLog_DateCreated] DEFAULT GETDATE(), 
	[DateDeleted] DATETIME NULL,
	[VersionUser] NVARCHAR(250) NOT NULL CONSTRAINT [REPORTING_ErrorLog_VersionUser] DEFAULT SYSTEM_USER,
	[VersionDate] DATETIME NOT NULL CONSTRAINT [REPORTING_ErrorLog_VersionDate] DEFAULT GETDATE()
)